﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace SwanEngine.Astar
{
    [Serializable]
    public class MapDataVo
    {
        /// <summary>
        /// 偏移量
        /// </summary>
        public int offsetX;
        public int offsetZ;

        /// <summary>
        /// 格子缩放
        /// </summary>
        public float gridScale = 1f;

        /// <summary>
        /// 行
        /// </summary>
        public int tileRow;
        /// <summary>
        /// 列
        /// </summary>
        public int tileCol;
        /// <summary>
        /// 格子数据
        /// </summary>
        public byte[,] tiles;

        public static MapDataVo Deserialize(byte[] bytes)
        {
            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream ms = new MemoryStream(bytes);
            MapDataVo data = bf.Deserialize(ms) as MapDataVo;//反序列化
            return data;
        }
    }
}